package com.bnz.search.controller;


import org.springframework.ui.Model;
import com.bnz.search.entity.ItemVo;
import com.bnz.search.service.ItemSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;


import java.io.IOException;
import java.util.Map;

@Controller
public class SearchController {
    @Autowired
    private ItemSearchService searchService;
    /**
     * 进行商品查询
     * @param vo  所有的查询参数
     * @return
     */
    @RequestMapping({"/","/search.html"})
    public String search(ItemVo vo, Model model) throws IOException {
        Map resultMap = searchService.search(vo);
        //结果放到model中
        model.addAttribute("resultMap",resultMap);
        //在前台锁住数据
        model.addAttribute("vo",vo);
        return "search";
    }
}
